package org.example.etl.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface PlanDataMapper {

    @Select(" SELECT COUNT(*) from airport_longlat where code4 =#{code4};")
    public boolean isDomesticThisLine(String code4);

    @Select(" SELECT COUNT(*) from airline_number where acid =#{acid};")
    public boolean isExistThisLine(String acid);


    @Update("update airline_number set count=count+1 where acid=#{acid+};")
    public void updateAnLineMsg(String acid);


    @Insert("insert into airline_number (acid,adepcode,adescode,adepname,adesname,adeplong,adeplat,adeslong,adeslat,count) values (#{acid},#{aDEP},#{aDES},(select airport_cname from kg_airport where airport_code4 = #{aDEP}),(select airport_cname from kg_airport where airport_code4 = #{aDES}),(select longitude from airport_longlat where code4 = #{aDEP}),(select latitude from airport_longlat where code4 = #{aDEP}),(select longitude from airport_longlat where code4 = #{aDES}),(select latitude from airport_longlat where code4 = #{aDES}),'1') ;")
    public void createAnLineMsg(String acid,String aDEP,String aDES);


    @Select(" SELECT COUNT(*) from airport_number where flightcode=#{code};")
    public boolean isExistThisAir(String code);



    @Insert("insert into airport_number (flightcode,cname,count) values (#{code},(select airport_cname from kg_airport where AIRPORT_CODE4 = #{code}),'1');")
    public void createAnAirMsg(String code);



    @Update("update airport_number set count=count+'1' where flightcode=#{code}; ")
    public void updateAnAirMsg(String code);

}
